package com.bbx.taxi.client.Util;

public class FormatUtil {
	/**
	 * 格式化电话号码，如：150****8265
	 */
	public static  String onFormatTelephone(String telephone) {
//		if(telephone==null||telephone.length()<11){
//			return "";
//		}
		if(telephone==null){
			return "";
		}
		telephone=telephone.replace("+86", "");
		String tel;
		StringBuffer sb = new StringBuffer(telephone);
		//暂时不掩码
//		tel = sb.substring(0, 3) + "****" + sb.substring(7, sb.length());
		tel=sb.toString();
		return tel;

	}
	/**
	 * 格式化价钱,分转化为元
	 */
	public static String onFormatPrice(int price){
		if(price<=0)return "0";
		double mprice=(double)price/100;
		java.text.DecimalFormat   df   =new   java.text.DecimalFormat("0.00");  
		String srt_price=df.format(mprice);
		try{
			double double_price=Double.parseDouble(srt_price);
			double xiaoshu=double_price-(int)double_price;
		if(xiaoshu==0){
			return (int)double_price+"";
		}}catch(Exception e){}
		return srt_price;
				
	}
	/**
	 * 格式化价钱,分转化为元
	 */
	public static String onFormatPrice(double price){
		if(price<=0)return "0";
		double mprice=(price/100);
		java.text.DecimalFormat   df   =new   java.text.DecimalFormat("0.00");  
		String srt_price=df.format(mprice);
		try{
			double double_price=Double.parseDouble(srt_price);
			double xiaoshu=double_price-(int)double_price;
		if(xiaoshu==0){
			return (int)double_price+"";
		}}catch(Exception e){}
		return srt_price;
				
	}
	/**
	 * 格式化价钱,分转化为元，并且进1，没有小数点
	 */
	public static String onFormatCeil(double price){
		if(price<=0)return "0";
		double mprice=(price/100);
		mprice= Math.ceil(mprice);
		java.text.DecimalFormat   df   =new   java.text.DecimalFormat("0.00");  
		String srt_price=df.format(mprice);
		try{
			double double_price=Double.parseDouble(srt_price);
			double xiaoshu=double_price-(int)double_price;
		if(xiaoshu==0){
			return (int)double_price+"";
		}}catch(Exception e){}
		return srt_price;
				
	}
	/**
	 * 格式化价钱,单位元，进1，没有小数点
	 */
	public static String onFormatDecimalCeil(double price){
		if(price<=0)return "0";
		double mprice=price;
		mprice= Math.ceil(mprice);
		java.text.DecimalFormat   df   =new   java.text.DecimalFormat("0.00");  
		String srt_price=df.format(mprice);
		try{
			double double_price=Double.parseDouble(srt_price);
			double xiaoshu=double_price-(int)double_price;
		if(xiaoshu==0){
			return (int)double_price+"";
		}}catch(Exception e){}
		return srt_price;
				
	}
	/**
	 * 格式化价钱,0.00格式
	 */
	public static String onFormatDecimal(double price){
		if(price<=0)return "0";
		java.text.DecimalFormat   df   =new   java.text.DecimalFormat("0.00");  
		String srt_price=df.format(price);
		try{
			double double_price=Double.parseDouble(srt_price);
			double xiaoshu=double_price-(int)double_price;
		if(xiaoshu==0){
			return (int)double_price+"";
		}}catch(Exception e){}
		return srt_price;
				
	}
	/**
	 * 格式化价钱,0.0格式
	 */
	public static String onFormatDecimal2(double price){
		if(price<=0)return "0";
		java.text.DecimalFormat   df   =new   java.text.DecimalFormat("0.0");  
		String srt_price=df.format(price);
		try{
			double double_price=Double.parseDouble(srt_price);
			double xiaoshu=double_price-(int)double_price;
		if(xiaoshu==0){
			return (int)double_price+"";
		}}catch(Exception e){}
		return srt_price;
				
	}
	public static float onFormatStar(float star){
		if(star==0.0)
			return 0;
		float mstar=star/(100/5);
		java.text.DecimalFormat   df   =new   java.text.DecimalFormat("0.0");  
		return Float.parseFloat(df.format(mstar));
	}
	public static float onFormatStar(double star){
		if(star==0.0)
			return 0;
		double mstar=star/(100/5);
		java.text.DecimalFormat   df   =new   java.text.DecimalFormat("0.0");  
		return Float.parseFloat(df.format(mstar));
	}
}
